// import Vue from 'vue';
// import VueRouter from 'vue-router';
if (VueRouter === undefined) {
  var VueRouter = window.VueRouter
}
import Library from './views/Library.vue';
const Class = () => import(/* webpackChunkName: "chunk-class" */'./components/top/Class.vue');
const Coding = () => import(/* webpackChunkName: "chunk-coding" */'./views/Coding.vue');

import Learn from './components/learn/Learn.vue';

const Poems = () => import(/* webpackChunkName: "chunk-poems" */'./views/Poems.vue');

const Pins = () => import(/* webpackChunkName: "chunk-pins" */'./views/Pins.vue');
// import CreateNews from "./components/news/CreateNews.vue";
// import ViewNews from "./components/news/ViewNews.vue";
const Articles = () => import(/* webpackChunkName: "chunk-articles" */'./views/Articles.vue');
const ViewPerson = () => import(/* webpackChunkName: "chunk-people" */'@v/people/ViewPerson.vue');
const PersonHome = () => import(/* webpackChunkName: "chunk-people" */'@v/people/PersonHome.vue');
const PersonHistory = () => import(/* webpackChunkName: "chunk-people" */'@v/people/PersonHistory.vue');
const PersonWorks = () => import(/* webpackChunkName: "chunk-people" */'@v/people/PersonWorks.vue');

import Works from './components/top/Works.vue';
import WorkArticles from './components/works/Articles.vue';
import Collections from './components/works/Collections.vue';
import Books from './components/works/Books.vue';
import Translations from './components/works/Translations.vue';
import Collaborations from './components/works/Collaborations.vue';

import EditArticle from './components/works/articles/EditArticle.vue';
import ViewArticle from './components/works/articles/ViewArticle.vue';

import EditCollection from './components/works/collections/EditCollection.vue';

import EditBook from './components/works/books/EditBook.vue';
import BookDetail from './components/works/books/BookDetail.vue';
import BookToc from './components/works/books/BookToc.vue';
import BookComments from './components/works/books/BookComments.vue';
import EditChapter from './components/works/books/EditChapter.vue';

import EditCollabBook from './components/works/collaborations/EditBook.vue';

import AddTranslation from './components/works/translations/AddTranslation.vue';

import People from './components/top/People.vue';
import Authors from './components/people/Authors.vue';
import PeopleView from './components/people/View.vue';
import EditAuthor from './components/people/EditAuthor.vue';

import Dev from './components/top/Dev.vue';
import Book from './components/book/Book.vue';
import Reader from './components/book/Reader.vue';
import Translater from './components/book/Translater.vue';
import Notes from './components/book/Notes.vue';
import Login from './components/user/Login.vue';
import Register from './components/user/Register.vue';

import ReviewBook from './components/reviews/ReviewBook.vue';
import ReviewPlan from './components/reviews/ReviewPlan.vue';
import ReviewChapter from './components/reviews/ReviewChapter.vue';

const ViewMat = () => import(/* webpackChunkName: "chunk-mats" */'./components/mats/ViewMat.vue');
const EditMat = () => import(/* webpackChunkName: "chunk-mats" */'./components/mats/EditMat.vue');
const EditPin = () => import(/* webpackChunkName: "chunk-pins" */'./components/mats/EditPin.vue');

import ImportProject from './components/coding/ImportProject.vue';

import Profile from './components/users/Profile.vue';

const EditGoal = () => import(/* webpackChunkName: "chunk-class" */'./components/class/EditGoal.vue');
const EditPlan = () => import(/* webpackChunkName: "chunk-class" */'./components/class/EditPlan.vue');

const routes = [
  {
    path: '/',
    redirect: '/poems'
  },
  {
    path: '/home',
    redirect: '/poems'
  },
  {
    path: '/library',
    component: Library
  },
  {
    path: '/learn',
    component: Learn
  },
  {
    path: '/poems',
    redirect: '/poems/fav'
  },
  {
    path: '/poems/fav',
    component: Poems,
  },
  {
    path: '/poems/discover',
    component: Poems,
  },
  {
    path: '/poems/resources',
    component: Poems,
  },
  {
    path: '/class',
    component: Class
  },
  {
    path: '/goals/edit',
    component: EditGoal
  },
  {
    path: '/plans/edit',
    component: EditPlan
  },
  {
    path: '/mats/view/:mid',
    component: ViewMat
  },
  {
    path: '/mats/file/*',
    component: ViewMat,
    meta: {iswide: true}
  },
  {
    path: '/mats/dir/*',
    component: ViewMat,
    meta: {isdir: true}
  },
  {
    path: '/mats/edit',
    component: EditMat 
  },
  {
    path: '/mats/edit/:mid',
    component: EditMat 
  },
  {
    path: '/mats/resources/edit/:mid',
    component: EditMat,
    meta: {
      isresource: true
    }
  },
  {
    path: '/pins',
    redirect: '/pins/fav'
  },
  {
    path: '/pins/fav',
    component: Pins,
  },
  {
    path: '/pins/discover',
    component: Pins,
  },
  {
    path: '/pins/edit',
    component: EditPin,
  },
  {
    path: '/articles',
    redirect: '/articles/fav',
  },
  {
    path: '/articles/fav',
    component: Articles 
  },
  {
    path: '/articles/discover',
    component: Articles
  },
  {
    path: '/works',
    component: Works,
    children: [
      {
        path: '',
        component: WorkArticles 
      },
      {
        path: 'articles',
        component: WorkArticles
      },
      {
        path: 'articles/:artid',
        component: ViewArticle
      },
      {
        path: 'edit',
        component: EditArticle
      },
      {
        path: 'edit/:id',
        component: EditArticle
      },
      {
        path: 'collections',
        component: Collections,
      },
      {
        path: 'collections/edit',
        component: EditCollection
      },
      {
        path: 'collections/edit/:colid',
        component: EditCollection
      },
      {
        path: 'books',
        component: Books
      },
      {
        path: 'books/edit',
        component: EditBook,
      },
      {
        path: 'books/edit/:bookid',
        component: EditBook,
      },
      {
        path: 'books/edit/:bookid/:chapid',
        component: EditChapter,
      },
      {
        path: 'books/detail/:bookid',
        component: BookDetail,
        children: [
          {
            path: 'toc',
            component: BookToc
          },
          {
            path: 'comments',
            component: BookComments
          }
        ]
      },
      {
        path: 'translations',
        component: Translations
      },
      {
        path: 'translations/add',
        component: AddTranslation
      },
      {
        path: 'translations/detail/:bookid',
        component: BookDetail,
        children: [
          {
            path: 'toc',
            component: BookToc
          },
          {
            path: 'comments',
            component: BookComments
          }
        ]
      },
      {
        path: 'collaborations',
        component: Collaborations
      },
      {
        path: 'collaborations/edit',
        component: EditCollabBook
      },
      {
        path: 'collaborations/edit/:bookid',
        component: EditCollabBook
      },
      {
        path: 'collaborations/detail/:bookid',
        component: BookDetail,
        children: [
          {
            path: 'toc',
            component: BookToc
          },
          {
            path: 'comments',
            component: BookComments
          }
        ]
      },
    ]
  },
  {
    path: '/translater/book/:bookid/:chapid',
    component: Translater
  },
  {
    path: '/notes',
    component: Notes
  },
  {
    path: '/p/:pid',
    redirect: '/p/:pid/home'
  },
  {
    path: '/p/:pid',
    component: ViewPerson,
    children: [
      {
        path: 'home',
        component: PersonHome,
      },
      {
        path: 'history',
        component: PersonHistory,
      },
      {
        path: 'works',
        component: PersonWorks,
      },
    ]
  },
  {
    path: '/people',
    component: People,
    children: [
      {
        path: 'authors',
        component: Authors
      },
      {
        path: 'authors/edit',
        component: EditAuthor
      },
      {
        path: 'authors/edit/:pid',
        component: EditAuthor
      }
    ]
  },
  {
    path: '/people/view/:pid',
    component: PeopleView
  },
  {
    path: '/book/:id',
    component: Book
  },
  {
    path: '/reader/:bookid',
    component: Reader
  },
  {
    path: '/reader/:bookid/:chapid',
    component: Reader
  },
  {
    path: '/user/register',
    component: Register
  },
  {
    path: '/user/login',
    component: Login
  },
  {
    path: '/coding',
    redirect: '/coding/fav'
  },
  {
    path: '/coding/fav',
    component: Coding
  },
  {
    path: '/coding/discover',
    component: Coding
  },
  {
    path: '/projects/:source/:organization/:project',
    redirect: '/projects/:source/:organization/:project/tree/master',
  },
  {
    name: "ViewMat",
    path: '/projects/:source/:organization/:project/:nodetype/:version',
    component: ViewMat,
    meta: {iswide: true}
  },
  {
    name: "ViewMat",
    path: '/projects/:source/:organization/:project/:nodetype/:version/*',
    component: ViewMat,
    meta: {iswide: true}
  },
  {
    path: '/coding/import',
    component: ImportProject
  },
  {
    path: '/dev',
    component: Dev
  },
  {
    path: '/review/book/:bookid',
    component: ReviewBook
  },
  {
    path: '/review/plan/:bookid',
    component: ReviewPlan
  },
  {
    path: '/review/chapter/:bookid/:chapid',
    component: ReviewChapter
  },
  {
    path: '/review/chapter/:bookid/:chapid/:sentid',
    component: ReviewChapter
  },
  {
    path: '/:user/',
    component: Profile,
  }
]

const router = new VueRouter({
  routes
});

export default router;